package com.wyp168.renrenfilm.core.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.wyp168.common.utils.R;
import com.wyp168.renrenfilm.core.feign.RenrenFastFeign;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

@Configuration
public class MyMetaObjectHandleConfiguration implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        System.out.println(LocalDateTime.now());
        LocalDateTime localDateTime = LocalDateTime.now();
        this.setFieldValByName("createdAt", localDateTime, metaObject);
        this.setFieldValByName("modifiedAt", localDateTime, metaObject);
//        this.strictInsertFill(metaObject, "createdAt", LocalDateTime.class, LocalDateTime.now());
//        this.strictInsertFill(metaObject, "modifiedAt", LocalDateTime.class, LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        System.out.println(LocalDateTime.now());
        System.out.println("------------------------进入到更新阶段>>>自动填充更新时间---------------------------");
//        this.strictUpdateFill(metaObject, "modifiedAt", LocalDateTime.class, LocalDateTime.now());
        this.setFieldValByName("modifiedAt", LocalDateTime.now(), metaObject);
    }

}
